<?php
	//自动结算一小时扫描数据库一次,超过7天时间自动结算
	file_put_contents("dingshi.txt", date("Y-m-d H:i:s") . "执行定时任务！短信自动提醒" . "\r\n", FILE_APPEND);  
	$rs=M('order')->field('order_id,order_sn,store_id,buyer_id,finnshed_time,order_amount,daiyan_sale,buyer_id,coupon')->where("order_state='30' and refund_state=0 and auto_sendinfo=0" )->select();
	foreach($rs as $key=>$value){
		$endtime=$value['shipping_time']+172800;
		$now=time();
		if($now>$endtime){
			$userinfo=M('users')->find($value['buyer_id']);
    		$data['username']=C('duanxin.username');
			$data['password']=C('duanxin.password');
			$data['mobile']=$userinfo['phone'];
			$data['content']='【58代言】 您的订单：'.$value['order_sn'].'已经发货，请即时确认收货.';
			$url=C('duanxin.url');
			$rs=post_url($url,$data);
		 
			$xml = simplexml_load_string($rs);
			$rs = json_decode(json_encode($xml),TRUE);
			if($rs['resultcode']==0){
				$data['auto_sendinfo']=1;
    			M('order')->where('order_id='.$value['order_id'])->save($data);
			}
    	}
	}

?>